layui.use(['element','form','layer','laypage'],function() {
	// body... 
	var element = window.layui.element,
		form = window.layui.form,
		layer = window.layui.layer,
		laypage = window.layui.laypage;
	laypage.render({
    elem: 'page' 
    ,count: 50 //数据总数，从服务端得到
    ,theme:'#fe5821'
  });
})
setTimeout(function() {
	// $(function (argument) {
	// 	/* body... */
	// 	console.log($('.nav [my]'))
	// 	$('.nav [my]').hover(function() {
	// 		/* Stuff to do when the mouse enters the element */
	// 		$(this).find('span').removeClass('layui-icon-up');
	// 		$(this).find('span').addClass('layui-icon-down')
	// 	}, function() {
	// 		/* Stuff to do when the mouse leaves the element */
	// 		$(this).find('span').removeClass('layui-icon-down');
	// 		$(this).find('span').addClass('layui-icon-up')
	// 	});
	// });
})

function find () {
	// body... 
	layer.closeAll();
	var find = "<div class='o-head'><img src='./img/open_head.png'><span class='o-close layui-icon layui-icon-close'><span></div>"+
					"<div class='o-con'>"+
						"<div class='o-guid o-find'><b>找回密码</b><span class='o-line'></span></div>"+
						"<div class='o-con-c'>"+
							"<span class='open-item'><input type='text' placeholder='手机号'><span class='o-clean layui-icon layui-icon-close-fill'></span></span>"+
							"<span class='open-item reg-img'><input type='text' placeholder='请输入图形验证码'><span class='o-img-ecode'>图形验证码</span><a href='javascript:void(0)' class='layui-icon layui-icon-refresh'></a></span>"+
							"<span class='open-item'><input type='password' placeholder='请输入短信验证码' class='o-code'><i class='o-code-line'></i><a href='javascript:void(0)' class='o-get-code'>获取验证码</a></span>"+
							"<span class='open-item'><input type='password' placeholder='设置密码'><span class='o-clean layui-icon layui-icon-close-fill'></span></span>"+
							"<span class='open-item'><input type='password' placeholder='重复密码'><span class='o-clean layui-icon layui-icon-close-fill'></span></span>"+
							"<button>重置密码</button>"+
							"<div class='o-tip'>还没账号？<a href='javascript:void(0)' onclick='register()'>立即注册</a></div>"+
						"</div>"+
					"</div>";

	layer.open({
			type:1,
			title:'',
			skin:'popup',
			resize:false,
			closeBtn: 0,
			content:find
		});

    open_close ();//关闭所有弹出层
	open_input ();//输入框焦点事件
}

function binding () {
	// body... 
	layer.closeAll();
	var bind = "<div class='o-head'><img src='./img/open_head.png'><span class='o-close layui-icon layui-icon-close'><span></div>"+
					"<div class='con'>"+
						"<div class='o-guid o-find'><b>绑定手机号</b><span class='o-line'></span></div>"+
						"<div class='o-con-c'>"+
							"<span class='open-item'><input type='text' placeholder='手机号'><span class='o-clean layui-icon layui-icon-close-fill'></span></span>"+
							"<span class='open-item'><input type='password' placeholder='请输入短信验证码' class='o-code'><i class='o-code-line'></i><a href='javascript:void(0)' class='o-get-code'>获取验证码</a></span>"+
							"<button>绑定</button>"+
						"</div>"+
					"</div>";
    
    layer.open({
			type:1,
			title:'',
			skin:'popup',
			resize:false,
			closeBtn: 0,
			content:bind
		});

    open_close ();//关闭所有弹出层
	open_change ();//弹出层内容切换
	open_input ();//输入框焦点事件
}

function open_close() {
	// body... 
	$('.popup .o-close').click(function(e) {
		/* Act on the event */
		layer.closeAll();
	});
}

function open_change () {
	// body... 
	$('.popup .o-guid a').click(function() {
		$(this).siblings('a').removeClass('on');
		$(this).addClass('on');
		var show ="#login_"+$(this).index();
		$('.o-con [con]').hide();
		$(show).show();
	});
}

function open_input () {
	// body... 
	$('input').focus(function() {
		/* Act on the event */
		$(this).css({'background':'#fff'});
	});
	$('input').blur(function() {
		/* Act on the event */
		if($(this).val() != ''){
			$(this).css({'background':'#fff'});
		}else {
			$(this).css({'background':'#f3f3f3'});
		}
		var parent = $(this).parent().parent(),state = 0;
		$(parent).find('input').each(function() {
			if($(this).val() == ''){
				state = 1;
			}
		});
		if(state == 0){
			$(parent).find('button').css({'background':'#fb4d4a','color':'#fff'});
		}else{
			$(parent).find('button').css({'background':'#f3f3f3','color':'#867d7d'});
		}
	});
	$('input').bind('input propertychange',function () {
		var parent = $(this).parent().parent(),state = 0;
		if($(this).val() != ''){
			$(this).parent().find('.o-clean').show();
		}else{
			$(this).parent().find('.o-clean').hide();
		}
		$(parent).find('input').each(function() {
			if($(this).val() == ''){
				state = 1;
			}
		});
		if(state == 0){
			$(parent).find('button').css({'background':'#fb4d4a','color':'#fff'});
		}else{
			$(parent).find('button').css({'background':'#f3f3f3','color':'#867d7d'});
		}
	});
	$('.o-clean').click(function() {
		/* Act on the event */
		$(this).parent().find('input').val('');
		$(this).parent().find('input').css({'background':'#f3f3f3'});
		$(this).hide();
	});
}